package game.johan.engine;

/*
Copyright (C) 2013 Johan Ceuppens

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/


import java.nio.ByteBuffer;
import java.util.LinkedList;


public class DrawMethodList
{
	EngineBase _base;
	LinkedList _list = new LinkedList();
	
	private int _currentindex;
	
	private Caretaker<DrawMethodList> _drawmethodresourcecaretaker = new Caretaker<DrawMethodList>();
	
	public DrawMethodList(EngineBase base) {
		
		_base = base;
		
	}

	public int size() {
		return _list.size();
	}

	public void clear() {
		_list.clear();
	}	
	
	public void add(DrawMethod surf) {
		_list.add(surf);
	}
	
	public DrawMethod get(int idx) {
		return (DrawMethod)(_list.get(idx));
	}
	
	public DrawMethod get() {
		//reform _currentindex at end to begin of list
		if (_currentindex >= _list.size())
			_currentindex = 0;
		return (DrawMethod)(_list.get(_currentindex++));
	}
	
	public void save() {
		_drawmethodresourcecaretaker.save(this);
	}
	
	public void restore() {
		_drawmethodresourcecaretaker.restore();
	}
	
}
